/**
 *
 * @author 
 *
 */
class Page6 extends egret.Sprite {
    private _main: Main;
    public constructor(main: Main) {
        super();
        this._main = main;
        
        
        //this.addEventListener(egret.TouchEvent.TOUCH_TAP,this.thisClick,this)
    }
    
    private touchMove(e: egret.TouchEvent): void {
        this.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.thisClickMove,this);
    }
    
    private mClickNum: number = 0;
    private mSkin: Boolean;
    private m_move_y = 0;
    private mChangeing: boolean;

    private thisClickMove(e: egret.TouchEvent): void {
        if(this.mChangeing) return;
        if(this.m_move_y == 0)
            this.m_move_y = e.stageY;
        else
            if(this.m_move_y > e.stageY)
            {
                this.mChangeing = true;
                egret.setTimeout(clean, this, 500);
                this._main.toPage7(this, true);
            }
            else if(this.m_move_y == e.stageY)
                ;
            else
        {
                this.mChangeing = true;
                egret.setTimeout(clean, this, 500);
                this._main.toPage5(this, false);
        }
        
        function clean(): void
        {
            this.mChangeing = false;
        }
    }
    
    private thisClick(e: egret.TouchEvent): void
    {
        this.mClickNum++;
        if(this.mClickNum == 1)
        {
            this.mSkin = true;
            return;
        }

        if(this.mClickNum >= 2)
        {
            this._main.toPage7(this, true);
            return;
        }
    }

    public start(): void {
        egret.setTimeout(this.touchMove,this,this.mSkin ? 0 : 500);
        
        var bg: eui.Image = new eui.Image;
        bg.source = "1_1_png";
        this.addChild(bg);
        
        var bg2: eui.Image = new eui.Image;
        bg2.source = "n_arrows_png";
        bg2.x = 300;
        bg2.y = 960;
        this.addChild(bg2);
        
        this.page1();
        this.page2();
        this.page3();
    }
    
    public page1(): void {
        var bg: eui.Image = new eui.Image;
        bg.source = "n_6_1_png";
        bg.x = -295;
        bg.y = 80;
        bg.alpha = 0;
        this.addChild(bg);

        egret.Tween.get(bg).to({
            x: 0,alpha:1,ease: egret.Ease.bounceInOut
        }, this.mSkin ? 0 :500)
    }
    
    public page2(): void {
        var bg: eui.Image = new eui.Image;
        bg.source = "n_6_2_png";
        bg.x = -300;
        bg.y = 200;
        bg.alpha = 0;
        this.addChild(bg);

        egret.Tween.get(bg).to({
            x: 70,alpha:1,ease: egret.Ease.bounceInOut
        }, this.mSkin ? 0 :500)
        
        
        var bg: eui.Image = new eui.Image;
        bg.source = "n_6_3_png";
        bg.x = -300;
        bg.y = 350;
        bg.alpha = 0;
        this.addChild(bg);

        egret.Tween.get(bg).wait(200 * 1).to({
            x: 70,alpha:1,ease: egret.Ease.bounceInOut
        }, this.mSkin ? 0 : 500);
        
        var bg: eui.Image = new eui.Image;
        bg.source = "n_6_4_png";
        bg.x = -300;
        bg.y = 500;
        bg.alpha = 0;
        this.addChild(bg);

        egret.Tween.get(bg).wait(200 * 2).to({
            x: 70,alpha:1,ease: egret.Ease.bounceInOut
        }, this.mSkin ? 0 : 500);
        
        var bg: eui.Image = new eui.Image;
        bg.source = "n_6_5_png";
        bg.x = -300;
        bg.y = 650;
        bg.alpha = 0;
        this.addChild(bg);

        egret.Tween.get(bg).wait(200 * 3).to({
            x: 70,alpha:1,ease: egret.Ease.bounceInOut
        }, this.mSkin ? 0 : 500);
    }
    
    public page3(): void {
        var bg: eui.Image = new eui.Image;
        bg.source = "n_6_6_png";
        bg.x = 320;
        bg.y = 1000;
        bg.alpha = 0;
        this.addChild(bg);

        egret.Tween.get(bg).to({
            y: 650,alpha:1,ease: egret.Ease.bounceInOut
        }, this.mSkin ? 0 : 500)
        
        var bg: eui.Image = new eui.Image;
        bg.source = "n_6_7_png";
        bg.x = 250;
        bg.y = 440;
        bg.alpha = 0;
        this.addChild(bg);

        egret.Tween.get(bg).wait(500 * 1).to({
            alpha: 1
        },this.mSkin ? 0 : 500)
    }
    
    public page4(): void {
        this.mClickNum = 1;
    }
}
